package com.t.bricks.bussiness.db.entity.rechargecard.base;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.t.bricks.annotation.DataInfo;
import com.t.bricks.utils.function.data.MoneyUtil;
import com.t.bricks.utils.function.date.TimeUtil;
import com.t.bricks.utils.function.encode.MD5Util;

/**
 * 充值卡'RechargeCard'表实体类
 * 警告:非数据库字段禁止在此添加,应该创建扩展实体中添加
 * @author HuangXinBian
 */
@ApiModel("充值卡RechargeCard")
@DataInfo(sDbName="BricksMall", sTableName="RechargeCard")
public class RechargeCardBase implements Serializable {

	private static final long serialVersionUID = 1L;// 使用rmi时需修改

	/**
	 * 记录编号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="uId", sComment="记录编号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=true, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=0 )
	@ApiModelProperty(value="记录编号", example="", position=0)
	//[end]
	protected String uId;

	/**
	 * 号码(不可重复)
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="sNo", sComment="号码(不可重复)", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=1 )
	@ApiModelProperty(value="号码(不可重复)", example="", position=1)
	//[end]
	protected String sNo;

	/**
	 * 激活码
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="sPass", sComment="激活码", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=64, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=2 )
	@ApiModelProperty(value="激活码", example="", position=2)
	//[end]
	protected String sPass;

	/**
	 * 标题(可重复)
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="sTitle", sComment="标题(可重复)", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=3 )
	@ApiModelProperty(value="标题(可重复)", example="", position=3)
	//[end]
	protected String sTitle;
	
	/**
	 * 金额(元)
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="mPrice", sComment="金额(元)", isDbField=true, sDbFileType="decimal",
		sDefaultData="0.01", isExtra=false, iskey=false, isNull=true,
		iMaxLength=10, isDecimal=false, iIntegralLength=6, iDecimalLength=2, iIndex=4 )
	@ApiModelProperty(value="金额(元)", example="0.01", position=4)
	//[end]
	protected BigDecimal mPrice;

	/**
	 * 开始时间
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//解决表单提交时字符串时间值错误
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="dStartDate", sComment="开始时间", isDbField=true, sDbFileType="datetime",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=23, isDecimal=false, iIntegralLength=-1, iDecimalLength=-1, iIndex=5 )
	@ApiModelProperty(value="开始时间", example="", position=5)
	//[end]
	protected Date dStartDate;

	/**
	 * 过期时间
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//解决表单提交时字符串时间值错误
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="dEndDate", sComment="过期时间", isDbField=true, sDbFileType="datetime",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=23, isDecimal=false, iIntegralLength=-1, iDecimalLength=-1, iIndex=6 )
	@ApiModelProperty(value="过期时间", example="", position=6)
	//[end]
	protected Date dEndDate;

	/**
	 * 激活时间
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//解决表单提交时字符串时间值错误
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="dActiv", sComment="激活时间", isDbField=true, sDbFileType="datetime",
		sDefaultData="", isExtra=false, iskey=false, isNull=true,
		iMaxLength=23, isDecimal=false, iIntegralLength=-1, iDecimalLength=-1, iIndex=7 )
	@ApiModelProperty(value="激活时间", example="", position=7)
	//[end]
	protected Date dActiv;

	/**
	 * 顾客账号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="sCustomerId", sComment="顾客账号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=true,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=8 )
	@ApiModelProperty(value="顾客账号", example="", position=8)
	//[end]
	protected String sCustomerId;

	/**
	 * 备注
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="sMemo", sComment="备注", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=true,
		iMaxLength=200, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=9 )
	@ApiModelProperty(value="备注", example="", position=9)
	//[end]
	protected String sMemo;

	/**
	 * 创建人
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="sCreator", sComment="创建人", isDbField=true, sDbFileType="varchar",
		sDefaultData="00000000", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=10 )
	@ApiModelProperty(value="创建人", example="00000000", position=10)
	//[end]
	protected String sCreator;

	/**
	 * 创建日期
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//解决表单提交时字符串时间值错误
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="dCreateDate", sComment="创建日期", isDbField=true, sDbFileType="datetime",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=23, isDecimal=false, iIntegralLength=-1, iDecimalLength=-1, iIndex=11 )
	@ApiModelProperty(value="创建日期", example="", position=11)
	//[end]
	protected Date dCreateDate;

	/**
	 * 修改人
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="sModifieder", sComment="修改人", isDbField=true, sDbFileType="varchar",
		sDefaultData="00000000", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=12 )
	@ApiModelProperty(value="修改人", example="00000000", position=12)
	//[end]
	protected String sModifieder;

	/**
	 * 修改日期
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//解决表单提交时字符串时间值错误
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="dModifiedDate", sComment="修改日期", isDbField=true, sDbFileType="datetime",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=23, isDecimal=false, iIntegralLength=-1, iDecimalLength=-1, iIndex=13 )
	@ApiModelProperty(value="修改日期", example="", position=13)
	//[end]
	protected Date dModifiedDate;

	/**
	 * 状态(枚举,1:待领;2:待用;3:已用;4:过期;5失效)
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="iState", sComment="状态(枚举,1:待领;2:待用;3:已用;4:过期;5失效)", isDbField=true, sDbFileType="int",
		sDefaultData="1", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=14 )
	@ApiModelProperty(value="状态(枚举,1:待领;2:待用;3:已用;4:过期;5失效)", example="1", position=14)
	//[end]
	protected Integer iState;

	/**
	 * 序号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="iIndex", sComment="序号", isDbField=true, sDbFileType="int",
		sDefaultData="1", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=15 )
	@ApiModelProperty(value="序号", example="1", position=15)
	//[end]
	protected Integer iIndex;

	/**
	 * 版本
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="iVersion", sComment="版本", isDbField=true, sDbFileType="int",
		sDefaultData="1", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=16 )
	@ApiModelProperty(value="版本", example="1", position=16)
	//[end]
	protected Integer iVersion;

	/**
	 * 记录验证串
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="sRecordKey", sComment="记录验证串", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=17 )
	@ApiModelProperty(value="记录验证串", example="", position=17)
	//[end]
	protected String sRecordKey;

	/**
	 * 检验失败次数
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="RechargeCard",
		sName="iErrorCount", sComment="检验失败次数", isDbField=true, sDbFileType="int",
		sDefaultData="0", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=18 )
	@ApiModelProperty(value="检验失败次数", example="0", position=18)
	//[end]
	protected Integer iErrorCount;

	/**
	 * 取 记录编号
	 * @return String
	 */
	public String getuId() {
		return uId;
	}

	/**
	 * 设置记录编号
	 * @param uId
	 */
	public void setuId(String uId) {
		this.uId = uId;
	}

	/**
	 * 取 号码(不可重复)
	 * @return String
	 */
	public String getsNo() {
		return sNo;
	}

	/**
	 * 设置号码(不可重复)
	 * @param sNo
	 */
	public void setsNo(String sNo) {
		this.sNo = sNo;
	}

	/**
	 * 取 激活码
	 * @return String
	 */
	public String getsPass() {
		return sPass;
	}

	/**
	 * 设置激活码
	 * @param sPass
	 */
	public void setsPass(String sPass) {
		this.sPass = sPass;
	}

	/**
	 * 取 标题(可重复)
	 * @return String
	 */
	public String getsTitle() {
		return sTitle;
	}

	/**
	 * 设置标题(可重复)
	 * @param sTitle
	 */
	public void setsTitle(String sTitle) {
		this.sTitle = sTitle;
	}

	/**
	 * 取 金额(元)
	 * @return Long
	 */
	public BigDecimal getmPrice() {
		return mPrice;
	}

	/**
	 * 设置 金额(元)
	 * @param mPrice
	 */
	public void setmPrice(BigDecimal mPrice) {
		this.mPrice = mPrice;
	}

	/**
	 * 取 开始时间
	 * @return Date
	 */
	public Date getdStartDate() {
		return dStartDate;
	}

	/**
	 * 设置开始时间
	 * @param dStartDate
	 */
	public void setdStartDate(Date dStartDate) {
		this.dStartDate = dStartDate;
	}

	/**
	 * 取 过期时间
	 * @return Date
	 */
	public Date getdEndDate() {
		return dEndDate;
	}

	/**
	 * 设置过期时间
	 * @param dEndDate
	 */
	public void setdEndDate(Date dEndDate) {
		this.dEndDate = dEndDate;
	}

	/**
	 * 取 激活时间
	 * @return Date
	 */
	public Date getdActiv() {
		return dActiv;
	}

	/**
	 * 设置激活时间
	 * @param dActiv
	 */
	public void setdActiv(Date dActiv) {
		this.dActiv = dActiv;
	}

	/**
	 * 取 顾客账号
	 * @return String
	 */
	public String getsCustomerId() {
		return sCustomerId;
	}

	/**
	 * 设置顾客账号
	 * @param sCustomerId
	 */
	public void setsCustomerId(String sCustomerId) {
		this.sCustomerId = sCustomerId;
	}

	/**
	 * 取 备注
	 * @return String
	 */
	public String getsMemo() {
		return sMemo;
	}

	/**
	 * 设置备注
	 * @param sMemo
	 */
	public void setsMemo(String sMemo) {
		this.sMemo = sMemo;
	}

	/**
	 * 取 创建人
	 * @return String
	 */
	public String getsCreator() {
		return sCreator;
	}

	/**
	 * 设置创建人
	 * @param sCreator
	 */
	public void setsCreator(String sCreator) {
		this.sCreator = sCreator;
	}

	/**
	 * 取 创建日期
	 * @return Date
	 */
	public Date getdCreateDate() {
		return dCreateDate;
	}

	/**
	 * 设置创建日期
	 * @param dCreateDate
	 */
	public void setdCreateDate(Date dCreateDate) {
		this.dCreateDate = dCreateDate;
	}

	/**
	 * 取 修改人
	 * @return String
	 */
	public String getsModifieder() {
		return sModifieder;
	}

	/**
	 * 设置修改人
	 * @param sModifieder
	 */
	public void setsModifieder(String sModifieder) {
		this.sModifieder = sModifieder;
	}

	/**
	 * 取 修改日期
	 * @return Date
	 */
	public Date getdModifiedDate() {
		return dModifiedDate;
	}

	/**
	 * 设置修改日期
	 * @param dModifiedDate
	 */
	public void setdModifiedDate(Date dModifiedDate) {
		this.dModifiedDate = dModifiedDate;
	}

	/**
	 * 取 状态(枚举,1:待领;2:待用;3:已用;4:过期;5失效)
	 * @return Integer
	 */
	public Integer getiState() {
		return iState;
	}

	/**
	 * 设置状态(枚举,1:待领;2:待用;3:已用;4:过期;5失效)
	 * @param iState
	 */
	public void setiState(Integer iState) {
		this.iState = iState;
	}

	/**
	 * 取 序号
	 * @return Integer
	 */
	public Integer getiIndex() {
		return iIndex;
	}

	/**
	 * 设置序号
	 * @param iIndex
	 */
	public void setiIndex(Integer iIndex) {
		this.iIndex = iIndex;
	}

	/**
	 * 取 版本
	 * @return Integer
	 */
	public Integer getiVersion() {
		return iVersion;
	}

	/**
	 * 设置版本
	 * @param iVersion
	 */
	public void setiVersion(Integer iVersion) {
		this.iVersion = iVersion;
	}

	/**
	 * 取 记录验证串
	 * @return String
	 */
	public String getsRecordKey() {
		return sRecordKey;
	}

	/**
	 * 设置记录验证串
	 * @param sRecordKey
	 */
	public void setsRecordKey(String sRecordKey) {
		this.sRecordKey = sRecordKey;
	}

	/**
	 * 取 检验失败次数
	 * @return Integer
	 */
	public Integer getiErrorCount() {
		return iErrorCount;
	}

	/**
	 * 设置检验失败次数
	 * @param iErrorCount
	 */
	public void setiErrorCount(Integer iErrorCount) {
		this.iErrorCount = iErrorCount;
	}

	/**
	 * 创建当前'记录验证串'
	 * @param key 加密密钥
	 * @return String 子节点集合
	 */
	public String createRecordKey(String key) {
		StringBuilder sb = new StringBuilder(1000);
		
		sb.append(null != this.uId ? String.valueOf(this.uId) : "").append(";");
		sb.append(null != this.sNo ? String.valueOf(this.sNo) : "").append(";");
		sb.append(null != this.sPass ? String.valueOf(this.sPass) : "").append(";");
		sb.append(null != this.sTitle ? String.valueOf(this.sTitle) : "").append(";");
		sb.append(null != this.mPrice ? MoneyUtil.BigDecimal2String(this.mPrice, 2) : "").append(";");
		sb.append(null != this.dStartDate ? TimeUtil.toStr(this.dStartDate, "YYYY-MM-dd HH:mm:00") : "").append(";");
		sb.append(null != this.dEndDate ? TimeUtil.toStr(this.dEndDate, "YYYY-MM-dd HH:mm:00") : "").append(";");
		sb.append(null != this.dActiv ? TimeUtil.toStr(this.dActiv, "YYYY-MM-dd HH:mm:00") : "").append(";");
		sb.append(null != this.sCustomerId ? String.valueOf(this.sCustomerId) : "").append(";");
		sb.append(null != this.sCreator ? String.valueOf(this.sCreator) : "").append(";");
		sb.append(null != this.dCreateDate ? TimeUtil.toStr(this.dCreateDate, "YYYY-MM-dd HH:mm:00") : "").append(";");
		sb.append(null != this.sModifieder ? String.valueOf(this.sModifieder) : "").append(";");
		sb.append(null != this.dModifiedDate ? TimeUtil.toStr(this.dModifiedDate, "YYYY-MM-dd HH:mm:00") : "").append(";");
		sb.append(null != this.iState ? String.valueOf(this.iState) : "").append(";");
		sb.append(null != this.iIndex ? String.valueOf(this.iIndex) : "").append(";");
		sb.append(null != this.iVersion ? String.valueOf(this.iVersion) : "").append(";");
		sb.append(key);

		return MD5Util.MD5(sb.toString());
	}
	
	/**
	 * 复制对象
	 * @param source 数据源
	 * @return RechargeCardBase
	 */
	public static RechargeCardBase copy(RechargeCardBase source) {
		if (null == source) {
			return null;
		}
		
		RechargeCardBase target = new RechargeCardBase();
		target.setuId(source.getuId());
		target.setsNo(source.getsNo());
		target.setsPass(source.getsPass());
		target.setsTitle(source.getsTitle());
		target.setmPrice(source.getmPrice());
		target.setdStartDate(source.getdStartDate());
		target.setdEndDate(source.getdEndDate());
		target.setdActiv(source.getdActiv());
		target.setsCustomerId(source.getsCustomerId());
		target.setsMemo(source.getsMemo());
		target.setsCreator(source.getsCreator());
		target.setdCreateDate(source.getdCreateDate());
		target.setsModifieder(source.getsModifieder());
		target.setdModifiedDate(source.getdModifiedDate());
		target.setiState(source.getiState());
		target.setiIndex(source.getiIndex());
		target.setiVersion(source.getiVersion());
		target.setsRecordKey(source.getsRecordKey());
		target.setiErrorCount(source.getiErrorCount());

		return target;
	}
	
	/**
	 * 克隆对象
	 * @return RechargeCardBase
	 */
	public RechargeCardBase clone() {
		return copy(this);
	}
	
}
